package base;


import aspect.UpdateOperationLog;
import base.response.OffsetLimitPage;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.ibatis.annotations.Param;
import java.util.List;

/**
 * 实现BaseService抽象类
 * Created by admin on 2017/01/07.
 */
public abstract class IBaseServicesWithBLOBsImpl<Record extends IBaseEntity, RecordWithBLOBs extends  Record, Example> extends IBaseServicesImpl<Record, RecordWithBLOBs, Example>  implements IBaseServicesWithBLOBs<Record, RecordWithBLOBs, Example> {

    @Override
    public abstract IBaseMapperWithBLOBs<Record, RecordWithBLOBs, Example> getMapper();

    public List<RecordWithBLOBs> selectByExampleWithBLOBs(Example example) throws Exception {
        return getMapper().selectByExampleWithBLOBs(example);
    }

    @UpdateOperationLog
    public int updateByExampleWithBLOBs(@Param("record") RecordWithBLOBs record, @Param("example") Example example) throws Exception {
        return getMapper().updateByExampleWithBLOBs(record,example);
    }
    @UpdateOperationLog
    public int updateByPrimaryKeyWithBLOBs(RecordWithBLOBs record) throws Exception {
        return getMapper().updateByPrimaryKeyWithBLOBs(record);
    }

    public OffsetLimitPage selectByExampleWithBLOBs(Example example, Integer offset, Integer limit) throws Exception {

        PageHelper.offsetPage(offset, limit);
        List<RecordWithBLOBs> recordList = getMapper().selectByExampleWithBLOBs(example);
        return new OffsetLimitPage((Page<Record>) recordList);

    }
}